package org.tech4j.edi.api.context;

import org.tech4j.edi.common.RetryHandle;
import org.tech4j.edi.common.entity.RetryBizConfig;
import org.tech4j.edi.common.entity.RetryBizRecord;
import org.tech4j.edi.common.enums.RetryStatusEnum;

import java.util.Date;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @program: tech4j
 * @description:
 * @author: YuKai Fan
 * @create: 2025/3/7 15:13
 **/
public class RetryContext {

    private String handleFactoryName = "cacheMap";

    /**
     * 重试记录
     */
    private final RetryBizRecord retryBizRecord;

    /**
     * 重试配置
     */
    private final RetryBizConfig retryBizConfig;

    private boolean force;

    private ExecutorService executorService;

    private Map<String, AtomicInteger> retrySlowCountMap;

    private RetryHandle retryHandle;

    public RetryContext(RetryBizRecord retryBizRecord, RetryBizConfig retryBizConfig) {
        this.retryBizRecord = retryBizRecord;
        this.retryBizConfig = retryBizConfig;
    }

    public RetryContext(RetryBizRecord retryBizRecord, RetryBizConfig retryBizConfig, boolean force) {
        this.retryBizRecord = retryBizRecord;
        this.retryBizConfig = retryBizConfig;
        this.force = force;
    }

    public RetryBizRecord getRetryBizRecord() {
        return retryBizRecord;
    }

    public RetryBizConfig getRetryBizConfig() {
        return retryBizConfig;
    }

    public boolean isForce() {
        return force;
    }

    public ExecutorService getExecutorService() {
        return executorService;
    }

    public void setExecutorService(ExecutorService executorService) {
        this.executorService = executorService;
    }

    public Map<String, AtomicInteger> getRetrySlowCountMap() {
        return retrySlowCountMap;
    }

    public void setRetrySlowCountMap(Map<String, AtomicInteger> retrySlowCountMap) {
        this.retrySlowCountMap = retrySlowCountMap;
    }

    public RetryHandle getRetryHandle() {
        return retryHandle;
    }

    public void setRetryHandle(RetryHandle retryHandle) {
        this.retryHandle = retryHandle;
    }

    public String getHandleFactoryName() {
        return handleFactoryName;
    }

    public void setHandleFactoryName(String handleFactoryName) {
        this.handleFactoryName = handleFactoryName;
    }
}
